﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tema
{
    class Client
    {
        private string _name;
        private int _age;
        private List<AbstractCar> _cars = new List<AbstractCar>();

        public Client(string name, int age)
        {
            _name = name;
            _age = age;
        }

        public string getName()
        {
            return _name;
        }

        public int getAge()
        {
            return _age;
        }

        public void setName(string name)
        {
            _name = name;
        }

        public void setAge(int age)
        {
            _age = age;
        }

        public void addCar(AbstractCar car)
        {
            _cars.Add(car);
        }

        public void deleteCar(AbstractCar car)
        {
            _cars.Remove(car);
        }

        public AbstractCar getCar(string carName)
        {
            foreach (AbstractCar car in _cars)
                if (car.getName().Equals(carName))
                    return car;
            return null;
        }

        public void printCars()
        {
            if (_cars.Count == 0)
            {
                Console.WriteLine("The client " + _name + " has no cars.");
            }
            else
            {
                Console.WriteLine("The client " + _name + " has the following cars: ");
                foreach (AbstractCar car in _cars)
                {
                    Console.WriteLine("Type: " + car.GetType().Name + " Name: " + car.getName() + " Color: " + car.getColor() + " Transmission: " + car.getTransmission());
                    car.printCharacteristics();
                }
            }
        }
    }
}
